﻿using ShopPowerTemplate.Common;
using ShopPowerTemplate.Entities;
using ShopPowerTemplate.WebServiceReference;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;

namespace ShopPowerTemplate.ViewModels
{
    public class CategoriesPresenterViewModel : BindableBase
    {
        private string _title = "Categorías";
        public string Title
        {
            get { return _title; }
            set { this.SetProperty(ref this._title, value); }
        }

        private ObservableCollection<CategoryPresenterViewModel> _items = new ObservableCollection<CategoryPresenterViewModel>();
        public virtual ObservableCollection<CategoryPresenterViewModel> Items
        {
            get { return this._items; }
            set { this.SetProperty(ref this._items, value); }
        }

        public CategoriesPresenterViewModel()
        {
            LoadCategoryList();
        }

        protected async virtual void LoadCategoryList()
        {
			try
            {
                Items = new ObservableCollection<CategoryPresenterViewModel>();
                WebServiceClient service = new WebServiceClient();
                foreach (var cat in await service.FindAllCategoryAsync())
                {
                    Items.Add(new CategoryPresenterViewModel(cat));
                }
			}
			catch (Exception ex)
            {
            }
        }

    }
}
